<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function foo() {
            console.log('这是foo函数体');

        }
        foo();
        function fn1() {
            console.log('这是fn1函数体');

        }
        var arr = [fn1, foo];
        arr[0]();
        arr[1]();
        function fn2(fun) {
            if (typeof fun == 'function') {
                fun();
            } else {
                console.log('error:这不是一个函数');

            }
        }
        var fn3 = function () {
            console.log('这是要执行的回调函数f3');

        }
        fn2(fn3);
        fn2(function () {
            console.log('这是需要执行的回调函数');

        })
    </script>
</body>

</html>